/*#include<iostream>
using namespace std;

const int N = 1010;
int q[N],h,t;
int main()
{
	int m,n,count = 0,tmp;
	cin >> m >> n;
	while(n--)
	{
		int x;
		cin >> x;
		tmp = 1;
		for(int i = h + 1;i <= t;i++)
		{
			if(x == q[i])
			{
				tmp = 0;
				break;
			}
		}
		if(tmp)
		{
			if(t - h == m)
			{
				h++;
			}
			q[++t] = x;
			count++;
		}
	}
	printf("%d",count);
	return 0;
} */

#include<iostream>
#include<queue>
using namespace std;

const int N = 1010;
queue<int> q;
int m,n;
bool st[N];

int main()
{
	cin >> m >> n;
	int cnt = 0;
	while(n--)
	{
		int x;
		cin >> x;
		if(st[x]) continue;
		cnt++;
		st[x] = true;
		q.push(x);
		if(q.size() > m)
		{
			st[q.front()] = false;
			q.pop();
		}
	}
	cout << cnt << endl; 
	return 0;
}

